﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// NotReviewedButNeeded
#pragma once
#include "NdbPropertySchemaType.h"
#include "NdbTypeTraits.h"
#include "OwnerPtr.h"
#include <vector>
#include <string>

namespace gcmp
{
    class IDbObjectArchive;
    class ElementId;
    class NdbObjectSchematic;
    class NdbObjectCloneable;
    class IDbObject;

    class GCMP_DATABASE_EXPORT NdbPropertySerializeUtils
    {
    public:
        static UInt64 SerializeRawPointer(
            IDbObjectArchive & objectArchive,
            NdbPropertyUtils::BehavioursAdapter adapter
        );

        static UInt64 SerializeValue(
            UInt64 valueSize,
            IntBaseType intBaseType,
            IntOrFloatType intOrFloatType,
            NdbPropertySchemaType schemaType,
            const std::vector<char> & valueData,
            IDbObjectArchive & objectArchive,
            NdbPropertyUtils::BehavioursAdapter adapter
        );

        static UInt64 SerializeValueWithoutHeader(
            UInt64 valueSize,
            const std::vector<char> & valueData,
            IDbObjectArchive & objectArchive
        );

        static UInt64 SerializeWString(
            const std::wstring & value,
            IDbObjectArchive & objectArchive,
            NdbPropertyUtils::BehavioursAdapter adapter
        );

        static UInt64 SerializeElementId(
            UInt64 valueSize,
            IntBaseType intBaseType,
            IntOrFloatType intOrFloatType,
            NdbPropertySchemaType schemaType,
            const ElementId & elementId,
            IDbObjectArchive & objectArchive,
            NdbPropertyUtils::BehavioursAdapter adapter
        );

        static UInt64 SerializeSchematicObject(
            const NdbObjectSchematic * pSchematicObject,
            IDbObjectArchive & objectArchive,
            NdbPropertyUtils::BehavioursAdapter adapter
        );

        static UInt64 SerializeCloneableObject(
            const NdbObjectCloneable * pCloneabeObject,
            IDbObjectArchive & objectArchive,
            NdbPropertyUtils::BehavioursAdapter adapter
        );

        static UInt64 SerializeIDbObject(
            const IDbObject * pIDbObject,
            IDbObjectArchive & objectArchive,
            NdbPropertyUtils::BehavioursAdapter adapter
        );

        static Int32 SerializeBlockHeaderPlaceholder(
            IDbObjectArchive & objectArchive
        );

        static UInt64 FillBackBlockHeader(
            Int32 headerLen,
            Int32 headerAttributes,
            UInt64 bodyLen,
            IDbObjectArchive & objectArchive
        );
    };
}

